well the functions are rather long and defined inline